<template>
  <div class="base-container">
    <t-tabs v-model="tabValue">
      <t-tab-panel v-for="(tab, tabIndex) in tabList" :key="tabIndex" :value="tab.value">
        <template #label>
          {{ tab.label }}
          <t-badge style="position: relative" :count="tab.count" show-zero :offset="[-6, 0]"></t-badge>
        </template>
        <div v-if="tab.value === '0'">
          <kjxm-list :isReview="false"/>
        </div>
        <div v-if="tab.value === '1'">
          <bzh-list :isReview="false"/>
        </div>
        <div v-if="tab.value === '2'">
          <kjsf-list :isReview="false"></kjsf-list>
        </div>
        <div v-if="tab.value === '3'">
          <wcx-list :isReview="false"></wcx-list>
        </div>
        <div v-if="tab.value === '4'">
          <cgzh-list :isReview="false"></cgzh-list>
        </div>
        <div v-if="tab.value === '5'">
          <ggxq-list :isReview="false"></ggxq-list>
        </div>
        <div v-if="tab.value === '6'">
          <kpzh-list @reload="reload" :isReview="false" />
        </div>
      </t-tab-panel>
    </t-tabs>
  </div>
</template>

<script>
import kjxmList from './components/kjxm-list.vue';
import bzhList from "./components/bzh-list.vue";
import WcxList from "./components/wcx-list.vue";
import kjsfList from "./components/kjsf-list.vue";
import cgzhList from "./components/cgzh-list.vue";
import ggxqList from "./components/ggxq-list.vue";
import kpzhList from "./components/kpzh-list.vue";


export default {
  name: 'reviewed-my',
  components: {
    WcxList,
    kjxmList,
    bzhList,
    kjsfList,
    cgzhList,
    kpzhList,
    ggxqList
  },
  data() {
    return {
      tabValue: '0',
      site_tag: import.meta.env.VITE_SITE_TAG,
      tabList: [
        {label: '科技项目', value: '0', count: 0},
        // {label: '标准化', value: '1', count: 0},
        // {label: '示范工程', value: '2', count: 0},
      ],
    };
  },
  created() {
    this.getKjxm();
    this.tabList.push({ label: '示范工程', value: '2', count: 0 })
    this.getKjsf();
    if (this.site_tag === 'jt') {
      this.getWcx();
      this.tabList.push({label: '微创新', value: '3', count: 0})
    }
    if(this.site_tag === 'jtt'){
      this.getCgzh();
      this.tabList.push({ label: '成果推广', value: '4', count: 0 })
      this.getGgxq();
      this.tabList.push({ label: '攻关需求', value: '5', count: 0 })
      this.getBzh();
      this.tabList.push({ label: '标准化', value: '1', count: 0 })
      this.getKpzh()
      this.tabList.push({ label: '科普综合', value: '6', count: 0 })
    }
  },
  methods: {
    getKjxm() {
      this.$api.zjk.expert
        .kjxmList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '0')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    },
    getBzh() {
      this.$api.zjk.expert
        .bzhList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '1')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    },
    getKjsf() {
      this.$api.zjk.expert
        .kjsfList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '2')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    },
    getWcx() {
      this.$api.zjk.expert
        .wcxList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '3')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    },
    getCgzh(){
      this.$api.zjk.expert
        .cgzhList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '4')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    },
    getGgxq(){
      this.$api.zjk.expert
        .ggxqList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '5')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    },
    getKpzh(){
      this.$api.zjk.expert
        .kpzhList('1', {})
        .then((res) => {
          const index = this.tabList.findIndex((val) => val.value === '6')
          this.tabList[index].count = res.total;
        })
        .catch((e) => {
          this.$message.error(e.toString());
          this.dataLoading = false;
        });
    }
  },
};
</script>

<style lang="less" scoped>
.t-tab-panel{
  padding: 10px;
}
/deep/ .t-badge--circle {
  position: relative;
}
</style>
